package com.ruoyi.manage.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.manage.domain.AttAttendanceSummary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.manage.mapper.AttAttendanceMapper;
import com.ruoyi.manage.domain.AttAttendance;
import com.ruoyi.manage.service.IAttAttendanceService;

/**
 * 员工考勤记录Service业务层处理
 * 
 * @author cf
 * @date 2025-06-03
 */
@Service
public class AttAttendanceServiceImpl implements IAttAttendanceService 
{
    @Autowired
    private AttAttendanceMapper attAttendanceMapper;

    /**
     * 查询员工考勤记录
     * 
     * @param id 员工考勤记录主键
     * @return 员工考勤记录
     */
    @Override
    public AttAttendance selectAttAttendanceById(Long id)
    {
        return attAttendanceMapper.selectAttAttendanceById(id);
    }

    /**
     * 查询员工考勤记录列表
     * 
     * @param attAttendance 员工考勤记录
     * @return 员工考勤记录
     */
    @Override
    public List<AttAttendance> selectAttAttendanceList(AttAttendance attAttendance)
    {
        return attAttendanceMapper.selectAttAttendanceList(attAttendance);
    }


    /**
     * 查询周期性考勤汇总（用于周/月/季/年等）
     *
     * @param type
     * @param date
     * @param beginTime
     * @param endTime
     */
    @Override
    public List<AttAttendanceSummary> selectAttendanceSummaryByPeriod(String type, String date, Date beginTime, Date endTime,Long staffId) {
        return attAttendanceMapper.selectAttendanceSummaryByPeriod(type, date, beginTime, endTime,staffId);
    }

    /**
     * @param beginTime
     * @param endTime
     * @return
     */
    @Override
    public List<AttAttendance> selectAttAttendanceByDateRange(Long staffId,String beginTime, String endTime) {
        return attAttendanceMapper.selectAttAttendanceByDateRange(staffId,beginTime, endTime);
    }

    /**
     * 新增员工考勤记录
     * 
     * @param attAttendance 员工考勤记录
     * @return 结果
     */
    @Override
    public int insertAttAttendance(AttAttendance attAttendance)
    {
        attAttendance.setCreateTime(DateUtils.getNowDate());
        return attAttendanceMapper.insertAttAttendance(attAttendance);
    }

    /**
     * 修改员工考勤记录
     * 
     * @param attAttendance 员工考勤记录
     * @return 结果
     */
    @Override
    public int updateAttAttendance(AttAttendance attAttendance)
    {
        attAttendance.setUpdateTime(DateUtils.getNowDate());
        return attAttendanceMapper.updateAttAttendance(attAttendance);
    }

    /**
     * 批量删除员工考勤记录
     * 
     * @param ids 需要删除的员工考勤记录主键
     * @return 结果
     */
    @Override
    public int deleteAttAttendanceByIds(Long[] ids)
    {
        return attAttendanceMapper.deleteAttAttendanceByIds(ids);
    }

    /**
     * 删除员工考勤记录信息
     * 
     * @param id 员工考勤记录主键
     * @return 结果
     */
    @Override
    public int deleteAttAttendanceById(Long id)
    {
        return attAttendanceMapper.deleteAttAttendanceById(id);
    }

    /**
     * @return
     */
    @Override
    public int countLateToday() {
        return attAttendanceMapper.countLateToday();
    }

    /**
     * @return
     */
    @Override
    public int countEarlyLeaveToday() {
        return attAttendanceMapper.countEarlyLeaveToday();
    }

    /**
     * @return
     */
    @Override
    public int countAbsentToday() {
        return attAttendanceMapper.countAbsentToday();
    }

    /**
     * @return
     */
    @Override
    public int countLeaveToday() {
        return attAttendanceMapper.countLeaveToday();
    }

}
